package com.example.cart.service.impl;


import com.example.cart.mapper.CarMapper;
import com.example.cart.model.Car;
import com.example.cart.service.CarService;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service("CarService")
public class CarServiceImpl implements CarService {

    @Resource
    private RedisTemplate<Object, Object> redisTemplate;

    @Resource
    private CarMapper carMapper;

    @Override
    public Integer addCar(Car car){ return carMapper.insertBySelective(car); }

    @Override
    public Integer updateCar(Car car){ return carMapper.updateByPK(car); }

    @Override
    public Integer deleteCar(Car car){ return carMapper.deleteByPK(car.getId()); }

    @Override
    public List<Car> getAll(){ return carMapper.selectAll(); }

    @Override
    public Integer getSearchCount(Map<String,Object> params){ return carMapper.selectCountBySearch(params); }

    @Override
    public  List<Car> searchCarsByPage(Map<String,Object> params){ return carMapper.selectBySearch(params); }

}
